<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>

<link href="<%=request.getContextPath()%>/conf_files/css/pagination.css" rel="stylesheet" type="text/css"/>
<SCRIPT src="<%=request.getContextPath()%>/conf_files/js/pagenav1.1.js" type=text/javascript></SCRIPT>
<script>
$(document).ready(function(){
	parent.$.messager.progress('close'); 
	var params = $.serializeObject($('#invenOrderSearchForm'));
	
	$('#dataGrid').datagrid({
		url : 'headqInventoryFlowJSONAction!searchInvenOrder',
		queryParams: params,
		fit : true,
		border : false,
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:true,
		pagination : true,
		pageSize : 15,
		pageList : [ 15, 30],	
		sortName : 'orderDate',
		sortOrder : 'desc',
		nowrap : false,
		showFooter:true,
		rowStyler: function(index,row){
			var style = "";
			if (row.status == 1)
				style += 'color:blue;';
			else if (row.status == 3)
				style += 'color:red;';

			if (row.type == 1)
				style += 'background-color:#F9F8FA;';
			return style;
		},
		columns : [ [ {
			field : 'id',
			title : '单据号',
			width : 50,
			align : 'center'
		},{
			field : 'storeName',
			title : '库房',
			width : 90,
			align : 'center'
				
		},{
			field : 'createByName',
			title : '创建人',
			width : 100,
			align : 'center'
				
		},{
			field : 'typeChainS',
			title : '单据种类',
			width : 120,
			align : 'center',
			sortable:true,
			order:'desc'	
		},{
			field : 'totalQuantity',
			title : '数量',
			align : 'center',
			width : 60
				
		},{
			field : 'statusS',
			title : '状态',
			width : 70,
			align : 'center'
				
		},{
			field : 'orderDate',
			title : '单据日期',
			width : 140,
			sortable:true,
			order:'desc'	
		},{
			field : 'lastUpdateDate',
			title : '最后修改日期',
			width : 140,
			sortable:true,
			order:'desc'	
		},{
			field : 'lastUpdateBy',
			title : '修改人',
			width : 120,
			align : 'center',
			sortable:true,
			order:'desc'	
		},{
			field : 'comment',
			title : '备注',
			width : 240
				
		}, {	
			field : 'action',
			title : '查看/修改',
			width : 80,
			align : 'center',
			formatter : function(value, row, index) {
				var str = '';

				if (row.id != 0){
				   var url = "<%=request.getContextPath()%>/action/headqInventoryFlowJSPAction!loadOrder?formBean.flowOrder.id=" + row.id;
					   str += $.formatString('<a href="#" onclick="addTab6(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="编辑"/></a>', url, row.typeChainS + row.id,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png');
				}
				return str;
			}
		}, {	
			field : 'download',
			title : '单据下载',
			width : 80,
			align : 'center',
			formatter : function(value, row, index) {
				var str = '';

				if (row.id != 0){
				   var url = "<%=request.getContextPath()%>/action/headqInventoryFlowJSPAction!downloadFlowOrder?formBean.flowOrder.id=" + row.id;
					   str += $.formatString('<a href="#" onclick="downloadOrder(\'{0}\');"><img border="0" src="{2}" title="编辑"/></a>', url, row.typeChainS + row.id,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/download3.png');
				}
				return str;
			}
		}]],
        onLoadSuccess: function(data) {
	        var tr = $(this).datagrid('getPanel').find('div.datagrid-body tr');
	        tr.each(function() {
	            $(this).children('td').children('div').css('height', '32px');
	        });
	    	 // 设置数据行垂直居中
	        $(this).datagrid('getPanel').find('.datagrid-body .datagrid-cell').css({
	            'display': 'flex',
	            'align-items': 'center'
	        });
	    },
		toolbar : '#toolbar',
	});
   
});
pageNav.fn = function(page,totalPage){                
	$("#currentPage").val(page);
    var params=$("#invenOrderSearchForm").serialize();  
    $.post("headqInventoryFlowJSONAction!searchInvenOrder",params, searchOrdersBackProcess,"json");	
};
function searchOrders(){
	var params = $.serializeObject($('#invenOrderSearchForm')); 
	$('#dataGrid').datagrid('load',params); 
    
    
}

//下载单据
function downloadOrder(url){
	
		document.invenOrderSearchForm.action = url;
		document.invenOrderSearchForm.submit();
}
function searchOrdersBackProcess(data){
	var orders = data.orders;
	var pager = data.pager;
	
    $('#invenOrders tr').each(function () {                
        $(this).remove();
    });

    if (orders.length != 0){
	    for (var i = 0; i < orders.length; i++){
	    	
	    	var j = i+1;
	    	var bg = "";
	    	if ((i % 2) == 0)
	    		bg = "<%=Common_util.EVEN_ROW_BG_STYLE%>";
     	    var color = "";
    	    if (orders[i].status == 3)
    		    color =  "<%=Common_util.CANCEL_ROW_FONT_COLOR%>";
    		else if (orders[i].status == 1)
        		color =  "<%=Common_util.DRAFT_ROW_FONT_COLOR%>";
	        if (orders[i] != "")  {
			    var urlLink = "headqInventoryFlowJSPAction!loadOrder?formBean.flowOrder.id=" + orders[i].id;
		        var nodeTitle = orders[i].typeChainS;
		        $("<tr class='InnerTableContent' style='" + bg + color +"' align='center'><td height='25'>"+(j + pager.firstResult)+
		        		  "</td><td>"+orders[i].id+
		        		  "</td><td>"+orders[i].storeName+
		        		  "</td><td>"+orders[i].createByName+
				          "</td><td>"+orders[i].typeChainS+
				          "</td><td>"+orders[i].orderDate+
				          "</td><td>"+orders[i].comment+
				          "</td><td>"+orders[i].totalQuantity+
				          "</td><td>"+orders[i].statusS+
				          "</td><td><a href='#'  onclick='addTab3(\""+urlLink+"\",\""+nodeTitle+"\")'><img src='<%=request.getContextPath()%>/conf_files/web-image/editor.gif' border='0'/></a></td></tr>").appendTo("#invenOrders");
	        }
	    }
	    renderPaginationBar(pager.currentPage, pager.totalPage);

		$("#org_table tr").mouseover(function(){      
			$(this).addClass("over");}).mouseout(function(){    
			$(this).removeClass("over");}); 
    }else {
    	$("<tr class='InnerTableContent'"+ bg +" align='center'><td colspan=6><font color='red'>对应条件没有查询信息</font> </td></tr>").appendTo("#invenOrders");
    }

    $("#invenFlowOrderDiv").show();
}
function changeChainStore(chainId){

}
</script>
</head>
<body>	
	
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 95px;">
	<s:form id="invenOrderSearchForm" name="invenOrderSearchForm"
		theme="simple" method="POST">
		<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								<div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div>
								<table width="100%" border="0">
									<tr class="PBAOuterTableTitale">
										<td height="35" colspan="10">库存单据:
										</td>
									</tr>
								 <tr class="InnerTableContent">
						      <td height="35">&nbsp;</td>
						      <td width="5%"><strong>单据日期：</strong></td>
						      <td width="18%">
						         <s:textfield id="startDate"  name="formBean.searchStartTime" cssClass="easyui-datebox" data-options="width:100,editable:false"/>			      
					      			&nbsp; 至&nbsp;
					      		 <s:textfield id="endDate" name="formBean.searchEndTime" cssClass="easyui-datebox" data-options="width:100,editable:false"/>	
		                      </td>
		                      <td width="5%"><strong>库房信息：</strong></td>
						      <td width="10%"><s:select  cssClass="easyui-combobox" style="width:140px" data-options="prompt:'选择库房',editable:false" 
						       name="formBean.flowOrder.storeId" size="1" id="storeId" list="uiBean.stores" listKey="id" listValue="name"  headerKey="-1" headerValue="" /></td>
				              

						      <td width="5%"><strong>单据种类：</strong></td>
						      <td width="10%"><s:select cssClass="easyui-combobox" style="width:140px" data-options="prompt:'选择种类'"
						       id="status" name="formBean.flowOrder.type"  list="uiBean.invenOrderTypes" listKey="key" listValue="value" headerKey="-1" headerValue="" /></td>
						      <td width="5%"><strong>单据状态：</strong></td>
						      <td width=""><s:select cssClass="easyui-combobox" style="width:140px" data-options="prompt:'选择状态'"
						       id="chainSaler" name="formBean.flowOrder.status"  list="uiBean.invenOrderStatus" listKey="key" listValue="value" headerKey="-1" headerValue="" /></td>
						      <td width="193">&nbsp;</td>
						    </tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</s:form>
	</div>
	<div data-options="region:'center',border:false"   >
			<table id="dataGrid" border="0">
			</table>
			<div id="toolbar" style="display: none;">
				<a onclick="searchOrders();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">搜索单据</a>
			</div>
		</div>
</div>	

</body>
</html>